#pragma once
#ifndef __LIT__RESOURCES__LIST__INCLUDED__HH__
#define __LIT__RESOURCES__LIST__INCLUDED__HH__

#ifdef LIT_OGRE_SUPPORT
	#include <Ogre.h>
#endif

#ifdef LIT_BOOST_SUPPORT
	#include <boost\function.hpp>
	#include <boost\bind.hpp>
#endif

#include <LitPrerequisites.h>
#include <LitFilePath.h>

namespace Lit
{
	class LIT_API ResourceLocation
	{
		FilePath mPath;
		String mType;
		String mGroup;
	public:
		ResourceLocation( ){}
		ResourceLocation( const FilePath &path, const String &type, const String &grp ) : mPath( path ), mType( type ), mGroup( grp ){}
		ResourceLocation( const ResourceLocation& rk ){ mPath = rk.mPath; mType=rk.mType; mGroup=rk.mGroup; }
		ResourceLocation& operator = ( const ResourceLocation& rk ){ mPath = rk.mPath; mType=rk.mType; mGroup=rk.mGroup; return *this; }
		~ResourceLocation(){}
		
		void setPath( const FilePath &path ){ mPath = path; }
		void setType( const String &type ){ mType = type; }
		void setGroup( const String &group ){ mGroup = group; }

		const FilePath &path() const{ return mPath; }
		const String &type() const{ return mType; }
		const String &group() const{ return mGroup; }
	};
	class LIT_API ResourceDescription
	{
		String mName;
		String mType;
		String mArchive;

	public:
		ResourceDescription( ){}
		ResourceDescription( const String &name, const String &type, const String &archive ) : mArchive( archive ), mName( name ), mType( type ){}
		ResourceDescription( const ResourceDescription& rk ){ mName = rk.mName; mArchive=rk.mArchive; mType=rk.mType; }
		ResourceDescription& operator = ( const ResourceDescription& rk ){ mName = rk.mName; mType=rk.mType; mArchive=rk.mArchive; return *this; }
		~ResourceDescription(){}
		
		const String &getName() const{ return mName; }
		const String &getType() const{ return mType; }
		const String &getArchive() const{ return mArchive; }

		void setName( const String & name ){ mName = name; }
		void setType( const String & type ){ mType = type; }
		void setArchive( const String &prev ){ mArchive = prev; }
	};

	class LIT_API ResourcesList 
	{
	public:
		typedef std::vector<ResourceDescription>					List;
		typedef std::vector<ResourceLocation>						LocationList;
		typedef boost::function<void(const ResourceDescription&)>	ResourceFoundCallback;

	public:
		ResourcesList( );
		ResourcesList( const ResourcesList& rk );
		ResourcesList& operator=( const ResourcesList& rk );
		~ResourcesList();
		

		void _dummy_resourceFoundCallback( const ResourceDescription& );

		void setResourceFoundCallback( ResourceFoundCallback cbk );
		ResourceFoundCallback& resourceFoundCallback();
		
#ifndef LIT_STANDALONE
		void updateLocationList();
		void updateMaterialList();
		void updateMeshList();
		void updateTextureList();
		void updateLists( );
		void updateCompositorList();
		
		const List& materials() const;
		const List& meshes() const;
		const List& textures() const;
		const List& compositors() const;
#endif
		const LocationList& locations() const;

	protected:
		ResourceFoundCallback mResourceFoundCallback;
		LocationList mLocations;

		List mMaterials;
		List mMeshes;
		List mTextures;
		List mParticles;
		List mCompositors;
	};

	typedef RefPtr<ResourcesList> ResourcesListPtr;
#endif
};